import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:dio/dio.dart';
import 'package:cached_network_image/cached_network_image.dart';

class MovieDetails extends StatefulWidget {
  final coverUrl;

  MovieDetails(this.coverUrl);

  @override
  State<StatefulWidget> createState() {
    return _MoviePage(coverUrl);
  }
}

class _MoviePage extends State<MovieDetails> {
  final coverUrl;

  _MoviePage(this.coverUrl);

  @override
  Widget build(BuildContext context) {
    return WillPopScope(child: CustomScrollView(
      slivers: <Widget>[
        SliverAppBar(
          leading: GestureDetector(
            child: Icon(Icons.arrow_back_ios),
            onTap: () => Navigator.pop(context),
          ),
          title: Text("ok的"),
          pinned: true,
          primary: true,
          expandedHeight: 260,
          flexibleSpace: FlexibleSpaceBar(
            background: Stack(
              fit: StackFit.expand,
              children: <Widget>[
                CachedNetworkImage(
                  imageUrl: coverUrl,
                  fit: BoxFit.cover,
                ),
                BackdropFilter(
                  filter: ImageFilter.blur(sigmaX: 8, sigmaY: 8),
                  child: new Container(
                    color: Colors.white.withOpacity(0.1),
                    child: Padding(
                      padding: EdgeInsets.only(top: 70, left: 30, right: 30),
                      child: Row(
                        children: <Widget>[
                          Hero(
                            tag: coverUrl,
                            transitionOnUserGestures: true,
                            child: CachedNetworkImage(
                              imageUrl: coverUrl,
                              fit: BoxFit.cover,
                              width: 110,
                              height: 165,
                            ),
                          )
                        ],
                      ),
                    ),
                  ),
                )
              ],
            ),
          ),
        ),
        SliverList(
            delegate: SliverChildBuilderDelegate(
                  (BuildContext context, int index) {
                return Text("oko");
              },
              childCount: 20,
            )),
      ],
    ), onWillPop: () async {
      Navigator.pop(context);
      return true;
    });
  }
}
